let app = getApp();
var httptool = require("../../utils/zry.httptool.js");
Page({
  data:{
    BottomId:'',//局ID
    BoxRecordId:'',//回合ID
    RecordShared:{},//分享的成绩列表
    ID:'',//打擂的成绩ID
    Title:'',//分享的title
    msgprop:'',//消息提示 
    productImg:'',//购买二维码
    sharVideoLink:'',//分享到朋友圈的视频连接地址
    shareImgUrl: 'http://mpic.tiankong.com/382/8a3/3828a395a0283ce2f899257e638a9188/640.jpg'
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    let that=this;
    let BottomId=options.BottomId;//局ID
    let BoxRecordId=options.BoxRecordId;//回合ID
    let ID=options.ID;//成绩ID
    that.setData({BottomId:BottomId,BoxRecordId:BoxRecordId,ID:ID});
    that.GetBoxRecordShared();
    that.getVideoLink();
    that.getImgUrl();
  },
   GetBoxRecordShared:function(){//获取分享的成绩列表
    let that = this;
    httptool.ajaxPost("api/BoxRecord/GetBoxRecordShared", {ID:that.data.ID }, function (res) {
      if (res.suc) {
          let data=res.data.Score;
          console.log("Title="+res.data.Title);
          that.setData({RecordShared:data,Title:res.data.Title});
      } else {
            app.showNotify(that, res.msg);
      }
    });
  },
  onShareAppMessage:function(res){
    let that=this;
    return {
      title: that.data.Title,
      desc: '打擂成绩分享',
      path:'/pages/sFrinedCircle/sharefriend?ID='+that.data.ID+"&UserId"+app.getStorage('customerId'),
      imageUrl: that.data.shareImgUrl
    }
  },
  goToBuy:function(e){//点击进入我要购买擂霸页面
    wx.navigateTo({
      url: '/pages/buyproduct/buyleiba',
    })
  },
  getImgUrl:function(e){//获取购买擂霸的二维码图片
    let that=this;
    httptool.ajaxPost("api/BannerPicture/GetBannerPictureByType", {BannerType:'BuyQRCode'}, function (res) { 
      if(res.suc){
          let datas=res.data;
          that.setData({productImg:datas[0].ImgUrl});
      }
    });
    httptool.ajaxPost("api/BannerPicture/GetBannerPictureByType", { BannerType: 'WxShare' }, function (res) {
      if (res.suc) {
        let datas = res.data;
        that.setData({ shareImgUrl: datas[0].ImgUrl });
      }
    });
  },
  getVideoLink:function(e){//获取视频连接地址
    let that=this;
     httptool.ajaxPost("api/Dictionary/GetDictionary", {DicType:6}, function (res) { 
        if(res.suc){
          let datas=res.data;
          //that.setData({sharVideoLink:});
        }
      })
  },
  videoErrorCallback: function(e) {
      console.log('视频错误信息:')
      console.log(e.detail.errMsg)
  }
})